<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习9</title>
</head>

<body>

</body>
<script>
    //1.练习:有一个黄色的小狗,叫大黄,今年已经三岁了,250斤的重量每次走路都很慢,喜欢吃大骨头
    let dog = {
        color: "黄色",
        name: "大黄",
        age: 3,
        weight: 250,

        walk: function () {
            return "走路都很慢";
        },

        eat: function () {
            return "喜欢吃大骨头";
        },
    };

    console.log(`有一个${dog.color}的小狗,叫${dog.name},今年已经${dog.age}岁了,${dog.weight}斤的重量每次${dog.walk()},${dog.eat()}`);


    //2.练习:创建一个手机对象,手机有型号,有颜色,可以打电话和发短信，并遍历对象属性输出
    // 创建手机对象（字面量方式）
    let phone = {
        brand: "iPhone 16",
        color: "黑色",

        call: function () {
            return "正在给打电话...";
        },

        sendMessage: function () {
            return "正在发送短信...";
        },
    };
    for (let key in phone) {
        if (typeof phone[key] !== 'function') {
            console.log(`${key}: ${phone[key]}`);
        }
    }    
</script>

</html>